using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Routing;

namespace Webbness.Mvc.Extensions
{
    public class LinkTo
    {
        /// <summary>
        /// Adds an action to the column.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="menuAction">The menu action.</param>
        /// <param name="title">The title.</param>
        /// <returns></returns>
        public static LinkToItem<T> Action<T>(Expression<Action<T>> menuAction, string title) where T : Controller
        {
            return new LinkToItem<T> {MenuAction = menuAction, Title = title, RouteValues = new RouteValueDictionary()};
        }

        /// <summary>
        /// Adds an action to the column.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="menuAction">The menu action.</param>
        /// <param name="title">The title.</param>
        /// <param name="routeValues">The route values.</param>
        /// <returns></returns>
        public static LinkToItem<T> Action<T>(Expression<Action<T>> menuAction, string title, object routeValues) where T : Controller
        {
            return new LinkToItem<T> {MenuAction = menuAction, Title = title, RouteValues = new RouteValueDictionary(routeValues)};
        }

        /// <summary>
        /// Adds a secure action to the column.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="menuAction">The menu action.</param>
        /// <param name="title">The title.</param>
        /// <returns></returns>
        public static LinkToItem<T> SecureAction<T>(Expression<Action<T>> menuAction, string title) where T : Controller
        {
            return new LinkToItem<T> { MenuAction = menuAction, Title = title, Secure = true, RouteValues = new RouteValueDictionary() };
        }

        /// <summary>
        /// Adds a secure action to the column.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="menuAction">The menu action.</param>
        /// <param name="title">The title.</param>
        /// <param name="routeValues">The route values.</param>
        /// <returns></returns>
        public static LinkToItem<T> SecureAction<T>(Expression<Action<T>> menuAction, string title, object routeValues) where T : Controller
        {
            return new LinkToItem<T> { MenuAction = menuAction, Title = title, Secure = true, RouteValues = new RouteValueDictionary(routeValues) };
        }
    }
}